#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "dtk_visualstate.h"

DTKVisualState* dtk_vs_create(DInt state, DPointer usrdata, DTKVisualStateAction action)
{
    DTKVisualState* vs;

    vs = (DTKVisualState*) malloc (sizeof(DTKVisualState));
    memset (vs, 0, sizeof(DTKVisualState));

    vs->state = state;
    vs->usrdata = usrdata;
    vs->action = action;
    dtk_link_init (DLINK(vs), (DPointer)vs);
    return vs;
}

DBoolean dtk_vs_active (DTKVisualState* self)
{
    if (self == NULL)
    {
        return;
    }

    if (self->action)
    {
        self->action (self->state, self->usrdata);
    }
    
    return;
}

void dtk_vs_free(DTKVisualState* vs)
{
    if (vs == NULL)
    {
        return;
    }

    free (vs);
    return;
}
